This sample is designed to illustrate specific compiler optimizations such as O1, O2 and O3.

This program computes the integral (area under the curve) of a user-supplied function over an interval in a stepwise fashion. The interval is split into segments, and at each segment position the area of a rectangle is computed whose height is the value of sine at that point and the width is the segment width. The areas of the rectangles are then summed.

The process is repeated with smaller and smaller width rectangles, more closely approximating the true value.

Compile the sample using different optimization options to create different optimized executables:

Read the Intel(R) C/C++ Compiler Documentation for more information about these options.

Some of these automatic optimizations use features and options that can restrict program execution to specific architectures.

Build Instructions

Use the one of the following compiler options:

Windows*:/O1,/O2,/O3,/Zi(build.bat [release|debug|run|clean]), edit the batch file to select the optimization level

Linux* and macOS*: -O1, -O2, -O3, -Os, -g(make [release|debug|run|clean]) and edit Makefile to select optimization level

The sample is also provided as Microsoft Visual Studio 2013*, 2015* and 2017* solutions.
To set the optimization level in the Visual Studio IDE under project properties set C/C++ > Optimization(/O1, /O2, /O3)